<template>
	<div>
		<scroll class="page-content" :on-refresh="onRefresh" :on-infinite="onInfinite">
			<slot></slot>
			<div v-if="$store.state.scroll.infiniteInit == 2" slot="infinite" class="text-center">没有更多数据</div>
		</scroll>
	</div>
</template>

<script>
	export default {
		data:function() {
			return {
				refreshInit:function(){},
				infiniteInit:function(){},
			}
		},
		mounted:function() {
			
		},
		methods: {
			onRefresh(done) {
				this.refreshInit = done	
				this.$store.commit('refreshInitChange',true)
			},
			onInfinite(done) {	
				this.infiniteInit = done	
				this.$store.commit('infiniteInitChange',1)
			}
		},
		watch:{
			'$store.state.scroll.refreshInit':function(){				
				if(!(this.$store.state.scroll.refreshInit))	{
					setTimeout(()=>{
						this.refreshInit()
					},500)
				}
			},
			'$store.state.scroll.infiniteInit':function(){
				if(this.$store.state.scroll.infiniteInit==0){
					setTimeout(()=>{
						this.infiniteInit()		
					},500)
				}
			}
		}
		
	}
</script>